import { AppDispatch } from './../index';
import { getArticlesByIdAPI } from '@/api/article';

export const getArticlesByIdAction = (data: {
  channel_id?: number;
  timestamp?: number;
}) => {
  return async (dispatch: AppDispatch) => {
    const res = await getArticlesByIdAPI(data);
    dispatch({
      type: 'article/saveList',
      payload: { ...res.data, channel_id: data.channel_id },
    });
    console.log('res  ----->  ', res);
  };
};

export const updateArticlesByIdAction = (data: {
  channel_id?: number;
  timestamp?: number;
}) => {
  return async (dispatch: AppDispatch) => {
    const res = await getArticlesByIdAPI(data);
    dispatch({
      type: 'article/updateListById',
      payload: { ...res.data, channel_id: data.channel_id },
    });
  };
};
